//
//  OAuthViewController.swift
//  weibo-anpeng
//
//  Created by 安鹏 on 16/1/13.
//  Copyright © 2016年 安鹏. All rights reserved.
//

import UIKit

class OAuthViewController: UIViewController {

    let webView = UIWebView()
    
    override func loadView() {
        view = webView
    }
    
    @objc private func close() {
        dismissViewControllerAnimated(true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        setNavBar()
        
        loadOAuthPage()
    }
    
    private func setNavBar() {
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "关闭", style: .Plain, target: self, action: "close")
    }
    
    private func loadOAuthPage() {
        let urlString = "https://api.weibo.com/oauth2/authorize?" + "client_id=" + "2310818548" + "&redirect_uri=" + "http://info.3g.qq.com"
        let url = NSURL(string: urlString)!
        let request = NSURLRequest(URL: url)
        webView.loadRequest(request)
    }

}
